package com.android.place360.place_search_result;

import android.util.Log;

import com.android.place360.google_places.PlaceResult;
import com.android.place360.place_detail.DetailResult;
public class PlaceItem implements Comparable {

	private PlaceResult placeResponse;
	private DetailResult detailResult;
	private int distance;
	private String distanceString;
	
	public PlaceItem() {
		super();
	}
	

	public int getDistance() {
		return distance;
	}


	public void setDistance(int distance) {
		this.distance = distance;
		if (distance >= 1000) {
			double dis = distance / 1000.0;
		
			String strDis = String.format("%.2f", dis);
			while (strDis.endsWith("0") || strDis.endsWith(".")) {
				strDis = strDis.substring(0,strDis.length() -1);
			}
			distanceString = strDis + " km";
			
		} else
			distanceString = distance+ " m";
	}

	public String getDistanceString(){
		return distanceString;
	}
	public void setPlaceResult(PlaceResult placeResponse) {
		this.placeResponse = placeResponse;
	}

	public PlaceResult getPlaceResult() {
		return placeResponse;
	}

	public void setDetailResult(DetailResult detailResult) {
		this.detailResult = detailResult;
	}

	public DetailResult getDetailResult() {
		return detailResult;
	}


	@Override
	public int compareTo(Object o) {
		return (int)(this.distance - ((PlaceItem) o).getDistance());
	}
	
}
